package com.chenxi.controller;

import com.ganyu.domain.ResponseResult;
import com.ganyu.domain.entity.Comment;
import com.ganyu.domain.vo.CommentListVo;
import com.ganyu.service.impl.CommentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.ganyu.constant.SystemConstant.ARTICLE_COMMENT;
import static com.ganyu.constant.SystemConstant.LINK_COMMENT;

/**
 * DATA: 2022/9/16
 * Author: 晨夕
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentServiceImpl commentServiceImpl;

    //显示文章详情评论
    @GetMapping("/commentList")
    public ResponseResult<CommentListVo> getCommentList(Long articleId, Integer pageNum, Integer pageSize){
        return commentServiceImpl.getCommentList(ARTICLE_COMMENT,articleId, pageNum, pageSize);
    }
    //添加评论
    @PostMapping
    public ResponseResult<CommentListVo> addComment(@RequestBody Comment comment){
        return commentServiceImpl.addComment(comment);
    }
    //显示友链评论
    @GetMapping("/linkCommentList")
    public ResponseResult<CommentListVo> getLinkCommentList(Long articleId, Integer pageNum, Integer pageSize){
        return commentServiceImpl.getCommentList(LINK_COMMENT,articleId, pageNum, pageSize);
    }
}
